public class GirlTest {
    public static void main(String[] args) {
    //生成一个数组来存储女孩
        Girl[] girls = new Girl[4];
    //创建新的对象
        Girl girl1 = new Girl("小紫",18,"女","绘画");
        Girl girl2 = new Girl("小红",18,"女","电影");
        Girl girl3 = new Girl("小陈",18,"女","游戏");
        Girl girl4 = new Girl("小白",18,"女","游泳");
    //将对象存储到数组中
        girls[0] = girl1;
        girls[1] = girl2;
        girls[2] = girl3;
        girls[3] = girl4;
    //遍历数组
        /*for(int i = 0;i < girls.length;i++){
            Girl girl = girls[i];
            System.out.println(girl.getName() + "," + girl.getAge() + "," + girl.getSex() + "," + girl.gethobby());
        }*/
        //计算年龄的平均数
        int sum = 0;
        for(int i = 0;i < girls.length;i++){
            Girl age = girls[i];
            sum += age.getAge();
        }
        int avg = sum / girls.length;
        System.out.println("平均年龄为：" + avg);
        //统计年龄低于平均值的个数，并将这些女孩的信息输出
        int count = 0;
        for(int i = 0;i < girls.length;i++){
            Girl age = girls[i];
            if(age.getAge() < avg){
              System.out.println("此女孩的年龄小于平均年龄，信息为：姓名：" + age.getName() + "  年龄：" + age.getAge() + "  性别：" + age.getSex() + "  爱好：" + age.gethobby());
              count++;
            }
        }
        if (count == 0){
            System.out.println("没有年龄低于平均年龄的女孩");
        }else{System.out.println("年龄低于平均值的个数为：" + count);}
    }
}
